package logic

import (
	"context"
	"serve/internal/global/model"

	"serve/internal/svc"
	"serve/videoSrv"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoPushLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoPushLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoPushLogic {
	return &VideoPushLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoPushLogic) VideoPush(in *videoSrv.VideoPushRequest) (*videoSrv.VideoPushResponse, error) {
	// todo: add your logic here and delete this line
	var Video = model.Video{
		UserId:    int(in.UserId),
		ClassId:   int(in.ClassId),
		Vip:       int(in.Viper),
		Url:       in.Url,
		ImageUrl:  in.ImageUrl,
		ShowCount: 0,
		Title:     in.Title,
		Len:       int(in.Len),
		Status:    0,
	}
	if err := model.DB.Create(&Video).Error; err != nil {
		return nil, err
	}
	return &videoSrv.VideoPushResponse{}, nil
}
